import delimited using "Ann_UnempRate_NSA.csv", clear

rename edr1northwest regR01000
rename edr2headwaters regR02000 
rename edr3arrowhead regR03000
rename edr4westcentral regR04000
rename edr5northcentral regR05000
rename edr6esouthwestcentral regR06E00
rename edr6wupperminnesotavalley regR06W00
rename edr7eeastcentral regR07E00
rename edr7wcentral regR07W00
rename edr8southwest regR08000
rename edr9southcentral regR09000
rename edr10southeast regR10000
rename edr117countytwincities regR11000

reshape long reg, i(yearmonth) j(spec_area) string

replace yearmonth=substr(yearmonth, 1,4)
destring yearmonth, replace
rename yearmonth year
rename reg ur

keep if year>=2005
tempfile a
save `a', replace

import delimited using "Ann_UnempRate_NSA_2.csv", clear


rename centralminnesota regCENT00
rename northeastminnesota regNE0000
rename northwestminnesota regNW0000
rename sevencountymplsstpaulmn regTC0000
rename southeastminnesota regSE0000
rename southwestminnesota regSW0000

reshape long reg, i(yearmonth) j(spec_area) string

replace yearmonth=substr(yearmonth, 1,4)
destring yearmonth, replace
rename yearmonth year
rename reg ur

keep if year<=2004

append using `a'

save ur_by_region.dta, replace



*********************************************************************************



import delimited using "Mth_UnempRate_NSA.csv", clear

rename edr1northwest regR01000
rename edr2headwaters regR02000 
rename edr3arrowhead regR03000
rename edr4westcentral regR04000
rename edr5northcentral regR05000
rename edr6esouthwestcentral regR06E00
rename edr6wupperminnesotavalley regR06W00
rename edr7eeastcentral regR07E00
rename edr7wcentral regR07W00
rename edr8southwest regR08000
rename edr9southcentral regR09000
rename edr10southeast regR10000
rename edr117countytwincities regR11000

reshape long reg, i(yearmonth) j(spec_area) string

gen year=substr(yearmonth,1,4)
gen month=substr(yearmonth,-2,2)
destring year month, replace
drop yearmonth

rename reg ur_quar

keep if year>=2005
tempfile a
save `a', replace

import delimited using "Mth_UnempRate_NSA_2.csv", clear

rename centralminnesota regCENT00
rename northeastminnesota regNE0000
rename northwestminnesota regNW0000
rename sevencountymplsstpaulmn regTC0000
rename southeastminnesota regSE0000
rename southwestminnesota regSW0000

reshape long reg, i(yearmonth) j(spec_area) string

gen year=substr(yearmonth,1,4)
gen month=substr(yearmonth,-2,2)
destring year month, replace
drop yearmonth

rename reg ur_quar

keep if year<=2004

append using `a'

gen date=ym(year, month)
format date %tm
gen date2=dofm(date)
gen quarter2=quarter(date2)

gen quarter=quarter(date)


save quarterly_ur_by_region.dta, replace





